<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
      window.onload=function(){
       var aLi=document.getElementsByTagName('li');
         for(var i=0;i<aLi.length;i++){
             //0 1 2 3 4 5 6 7 8 9 10...
             if(i%2==0){
                 //0 2 4 6 8 10 偶数
                 aLi[i].style.background='#ccc';
             }
             else{
                 //1 3 5 7 9  基数
                 aLi[i].style.background='';
             }
         }
      };
    </script>
</head>
<body>
  <ul>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
  </ul>
</body>
</html>